<?php
//活动表

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Casts\Attribute;

class RateDurationModel extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'rate_duration';

    const RATES = [5, 60];
    const FOLLOWING = 1;   // 是否在关注中，1为是，2为否
    const UNFOLLOWED = 2;

    // 访问器
    protected function rate(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 100,
        );
    }
}
